def fib(n):
    '''
    包括指定项的斐波那契数列
    :param n: 项数
    :return:  斐波那契数列生成器
    '''
    n1 = 1
    n2 = 1
    len = 0
    while len < n:
        yield n1
        n1, n2 = n2, n1 + n2
        len += 1


f = fib(6)
while True:
    try:
        print(next(f))
    except StopIteration as e:
        print('访问结束')
        break
